﻿<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Gramos - Admin Dashboard</title>

    <!-- begin::global styles -->
    <link rel="stylesheet" href="assets/vendors/bundle.css" type="text/css">
    <!-- end::global styles -->

    <!-- begin::custom styles -->
    <link rel="stylesheet" href="assets/css/app.css" type="text/css">
    <!-- end::custom styles -->

</head>
<body class="bg-white h-100-vh p-t-0">

<!-- begin::page loader-->
<div class="page-loader">
    <div class="spinner-border"></div>
    <span>Loading ...</span>
</div>
<!-- end::page loader -->

<div class="p-b-50 d-block d-lg-none"></div>

<div class="container h-100-vh">
    <div class="row align-items-md-center h-100-vh">
        <div class="col-lg-6 d-none d-lg-block">
            <img class="img-fluid" src="assets/media/svg/register.svg" alt="...">
        </div>
        <div class="col-lg-4 offset-lg-1">
            <h3>Register</h3>
            <p>Create a new account</p>
            <!--            收集注册信息的form-->
            <form id="regist_form">
                <div class="form-group mb-4">
                    <input type="text" name="name" class="form-control form-control-lg" autofocus
                           placeholder="Username">
                </div>
                <!--                暂时用不上这个-->
                <!--                <div class="form-group mb-4">-->
                <!--                    <input type="email" class="form-control form-control-lg" placeholder="Email">-->
                <!--                </div>-->
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group mb-4">
                            <input type="password" name="password" class="form-control form-control-lg"
                                   placeholder="Password">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group mb-4">
                            <input type="password" class="form-control form-control-lg" placeholder="Password">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="custom-control custom-switch">
                        <input type="checkbox" class="custom-control-input" id="customSwitch" checked="">
                        <label class="custom-control-label" for="customSwitch">I agree to the Terms and Privacy.</label>
                    </div>
                </div>
                <!--                调教表单的按钮-->
                <button type="button" onclick="regist()" class="btn btn-primary btn-lg btn-block btn-uppercase mb-4">
                    Create Account
                </button>
                <p class="text-right">
                    <a href="#" class="text-underline">Already a user?</a>
                </p>
            </form>
        </div>
    </div>
</div>
</body>

<!-- begin::global scripts -->
<script src="assets/vendors/bundle.js"></script>
<!-- end::global scripts -->

<!-- begin::custom scripts -->
<script src="assets/js/app.js"></script>
<!-- end::custom scripts -->
<!--引入jq-->
<script src="assets/js/jquery.min.js"></script>
<script>
    // 注册的函数
    function regist() {
        // 1获取表单的数据
        let data = $('#regist_form').serializeArray();
        // 2 使用ajax异步获取发送请求
        // 四个参数分别是 url， 参数， 回调函数(他会接受一个返回的参数)， 数据格式
        $.post("/user/registUser", data, function (result) {
            // 判断是否ok
            if (result.ok == true) {
                alert("注册成功");
                window.location.href = "login.html"
            } else {
                alert(result.message)
            }
        }, 'json')
    }
</script>
</body>
</html>